package com.qk.management.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class TimeCountAspect {

    @Pointcut(value = "execution(* com.qk.management.service.*.*(..))")
    public void pt(){

    }

    @Around("pt()")
    public Object timeCount(ProceedingJoinPoint pjp) throws Throwable{
        long start = System.currentTimeMillis();
        Object proceed = pjp.proceed();
        long end = System.currentTimeMillis();

        String className = pjp.getTarget().getClass().getName();
        String methodName = pjp.getSignature().getName();
        log.info(className+"中方法名"+methodName+"耗时:{}",end-start);
        return proceed;
    }

}
